// JavaScript Document
	
   $(function(){
        if (!window.localStorage){
          function createCookie(name,value,days) {
            if (days) {
              var date = new Date();
              date.setTime(date.getTime()+(days*24*60*60*1000));
              var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
          }

          function readCookie(name) {
            var result = ""
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
              var c = ca[i];
              while (c.charAt(0)==' ') c = c.substring(1,c.length);
              if (c.indexOf(nameEQ) == 0){
                 result = c.substring(nameEQ.length,c.length);
              }else{
                result = "";
              }
           }
            return(result);
          }
          localStorage = (function () {
            return {
              setItem: function (key, value) {
                createCookie(key, value, 3000)
              },

              getItem: function (key) {
                return(readCookie(key));
              }
            };
          })();
        }

        load_settings();

        $('#content').submit(function(event){
          event.preventDefault();
          save_settings();
        });
      });
	  
 function save_settings(){
     //   localStorage.setItem("background_color", $("#background_color").val());
     //  localStorage.setItem("text_color", $("#text_color").val());
        localStorage.setItem("text_size", $("#text_size").val());
        apply_preferences_to_page();
		//location.href = "chunji.html";
		history.back();
      }
	  
  function apply_preferences_to_page(){
    //    $("#content").css("backgroundColor", $("#background_color").val());
   //     $("#content").css("color", $("#text_color").val());
        $("#content").css("fontSize", $("#text_size").val() + "px");
		$("#content2").css("fontSize", $("#text_size").val() + "px");
		$("#content3").css("fontSize", $("#text_size").val() + "px");
		$("#content4").css("fontSize", $("#text_size").val() + "px");
		$("#content5").css("fontSize", $("#text_size").val() + "px");
		$("#content6").css("fontSize", $("#text_size").val() + "px");
		$("#content7").css("fontSize", $("#text_size").val() + "px");
		$("#content8").css("fontSize", $("#text_size").val() + "px");
		$("#content9").css("fontSize", $("#text_size").val() + "px");
		$("#content10").css("fontSize", $("#text_size").val() + "px");
		$("#content11").css("fontSize", $("#text_size").val() + "px");
		$("#content12").css("fontSize", $("#text_size").val() + "px");
		$("#content13").css("fontSize", $("#text_size").val() + "px");
		$("#content14").css("fontSize", $("#text_size").val() + "px");
		$("#content15").css("fontSize", $("#text_size").val() + "px");
		$("#content16").css("fontSize", $("#text_size").val() + "px");
		$("#content17").css("fontSize", $("#text_size").val() + "px");
		$("#content18").css("fontSize", $("#text_size").val() + "px");
		$("#content19").css("fontSize", $("#text_size").val() + "px");
		$("#content20").css("fontSize", $("#text_size").val() + "px");
		$("#content21").css("fontSize", $("#text_size").val() + "px");
		$("#content22").css("fontSize", $("#text_size").val() + "px");
		$("#content23").css("fontSize", $("#text_size").val() + "px");
		$("#content24").css("fontSize", $("#text_size").val() + "px");
		$("#content25").css("fontSize", $("#text_size").val() + "px");
		$("#content26").css("fontSize", $("#text_size").val() + "px");
		$("#content27").css("fontSize", $("#text_size").val() + "px");
		$("#content28").css("fontSize", $("#text_size").val() + "px");
		$("#content29").css("fontSize", $("#text_size").val() + "px");
		$("#content30").css("fontSize", $("#text_size").val() + "px");
		$("#content31").css("fontSize", $("#text_size").val() + "px");
		$("#content32").css("fontSize", $("#text_size").val() + "px");
		$("#total").css("fontSize", $("#text_size").val() + "px");
      }

      function load_settings(){
      //  var bgcolor = localStorage.getItem("background_color");
      //  var text_color = localStorage.getItem("text_color");
	 //  var bgcolor = "#309";
	//	var text_color = "#000000";
        var text_size = localStorage.getItem("text_size");
        if(text_size == null)
        	text_size = "40";

     //   $("#background_color").val(bgcolor);
   //     $("#text_color").val(text_color);
        $("#text_size").val(text_size);

        apply_preferences_to_page();
	  }

